package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.biz.AdminBiz;
import com.entity.Qc_admin;

public class AdminLoginServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session=request.getSession();
		String adminname=request.getParameter("loginId");
		String adminpwd=request.getParameter("password");
		
		Qc_admin qa=new Qc_admin();
		qa.setAdmin_name(adminname);
		qa.setAdmin_pwd(adminpwd);
		
		AdminBiz ab=new AdminBiz();
		Qc_admin qca=ab.adminLogin(qa);
		if (qca!=null) {
			session.setAttribute("LOGIN", qca);
			response.sendRedirect("mainform.html");
		}else{
			response.sendRedirect("index.jsp");
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
